package com.example.jh352160.surfingtv.thematic_details.customView;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bumptech.glide.Glide;
import com.example.jh352160.surfingtv.R;

/**
 * Created by jh352160 on 2016/8/4
 */

public class AllcommodityTabItem extends LinearLayout {

    Context context;
    ImageView imageView;
    View lineView;

    public AllcommodityTabItem(Context context, String imageUrl) {
        super(context);
        this.context = context;
        init();
//        imageView.setImageResource(imageId);
        Glide.with(context).load(imageUrl).into(imageView);
    }

    public AllcommodityTabItem(Context context) {
        super(context);
        this.context = context;
        init();
    }

    public AllcommodityTabItem(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        init();
    }

    private void init() {
        LayoutInflater.from(context).inflate(R.layout.allcommidity_tab_item, this);
        imageView = (ImageView) findViewById(R.id.imageView);
        int i=imageView.getMaxWidth();
        lineView = findViewById(R.id.lineView);
    }

    public void setSelect(boolean isSelect) {
        if (isSelect) {
            lineView.setVisibility(VISIBLE);
            imageView.setPadding(0, 0, 0, 0);
        } else {
            lineView.setVisibility(INVISIBLE);
            imageView.setPadding(0, 20, 0, 0);
        }
    }

}
